<?php
session_start();
if(!ob_start("ob_gzhandler")) ob_start();
?>
<html>
	<head>
		<title></title>
		<link rel = "stylesheet" type = "text/css" href = "mainFrame.css">
		<script type='text/javascript' src='jquery-1.7.js'></script>
		<script type = 'text/javascript' src = 'jquery-ui-1.8.16.custom.min.js'></script>
	</head>
		<body>
		<h3>Friends:</h3>
		<?php
	mysql_connect("localhost", "sapmenet_admin", "a1s2d3f4g5h6j7") or die ("Problem with datebase");
	mysql_select_db("sapmenet_users");
	if (isset($_SESSION['JID']))
	{
		
	}
	else{
		header ('Location: ..\index.php');
		exit();
	}
	$showFriends = "SELECT concat(users.firstName, ' ', users.lastName) AS fullName, users.mainPic, users.ID FROM friendships JOIN users ON friendships.friendId = users.Id WHERE friendships.userId = {$_SESSION['id']}";
	$showFriends= mysql_query($showFriends);
	echo"<div id='allFriends'>";
	while($result = mysql_fetch_array($showFriends, MYSQL_NUM))
	{
		$pic=$result[1]."mini.jpg";
		echo"<div><img src = 'Icons/close.png' class = 'delFriend' id = '".$result[2]."' title = 'Remove friend'><a href=http://sapme.net/Framework/profilePage.php?id=".$result[2]."><div class='friendPanel'><div class='friendPicture'><img src='".$pic."'></div><div class='friendName'> ".$result[0]."</div></div></a></div><br>";
	}
	echo "</div>";
	?>
		<script>
			$(".delFriend").click(function()
			{
				$(".delFriend").removeClass("bomba");
				$(this).addClass("bomba");
				var deleteFriendId = $(".bomba").attr("id");
				$.post("deleteFriendship.php", {delId : deleteFriendId}, function(data)
				{
					$("#mainFrame").load("friends.php");
				});
			});
		</script>
		</body>
</html>	

























